﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Catering.View_Operaction;


namespace Catering
{
    public partial class NoticeEdit : System.Web.UI.Page
    {
        // 属性注入
        Catering_Rules.Announcement AnnounRule = new Catering_Rules.Announcement();
        Catering_Model.Announcement AnnounModel = new Catering_Model.Announcement();
        
        
        

        // 页面 Load 事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int Id = Convert.ToInt32(Request.QueryString["id"]);
                ViewState["id"] = Id;
                Catering_Rules.T_Personnel pRule = new Catering_Rules.T_Personnel();
                
                Catering_Model.Announcement AnnounModel = AnnounRule.GetModel(Id);
                lblTitle.Text = AnnounModel.Title;

                string fileList = AnnounModel.temp1;
                string nameList = string.Empty;
                IList<Catering_Model.Announcement> fileUploadList1 = new List<Catering_Model.Announcement>();
                IList<String> fileUploadList = new List<String>();
                if (!string.IsNullOrEmpty(fileList)) fileUploadList = fileList.Split('|');
                foreach (var item in fileUploadList)
                {

                    if (!string.IsNullOrEmpty(item))
                    {
                        IList<String> list = new List<String>();
                        list = item.Split(new string[1] { "@@" }, StringSplitOptions.None);
                        if (list.Count > 1) nameList = list[1];
                        Catering_Model.Announcement model = new Catering_Model.Announcement();
                        model.temp1 = HttpUtility.UrlEncode(nameList);
                        model.temp2 = HttpUtility.UrlEncode(item);
                        model.Title = nameList;
                        fileUploadList1.Add(model);
                    }
                }

                this.NoticeRept.DataSource = fileUploadList1;
                this.NoticeRept.DataBind();

                Catering_Model.E_Personnel pmodel = pRule.GetModel(AnnounModel.UserId);

                lblUserAndTime.Text = string.Format("{0}     {1}", AnnounModel.Release, pmodel.Name);
                td_content.InnerHtml=AnnounModel.Conent;
            }
        }

        // 修改事件处理
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                //int Id = Convert.ToInt32(ViewState["id"]);
                //Catering_Model.Announcement AnnounModel = AnnounRule.GetModel(Id);

                //AnnounModel.Title = this.txt_Title.Text.Trim();
                //AnnounModel.Conent = this.ftxt_Conent.Text.Trim();
                //AnnounModel.Release = System.DateTime.Now;

                //AnnounRule.Update(AnnounModel);
                //Response.Redirect("NoticeManage.aspx");
            }
        }
    }
}